{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1b45222f",
   "metadata": {},
   "source": [
    "# python\n",
    "\n",
    "#### python第一行代码\n",
    "* print\"hello word\"\n",
    "\n",
    "#### pycharm安装教程\n",
    "\n",
    "1.  搜索pycharm官网下载链接[官网](https://www.jetbrains.com/pycharm/download/#section=windows)\n",
    "2.  点击下载\n",
    "\n",
    "#### anaconda安装教程\n",
    "1. 点击老师分享的清华anaconda安装链接\n",
    "2. 点击下载\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c39655a7",
   "metadata": {},
   "source": [
    "### jupyter notebook 的使用\n",
    "1. 在jupyter官网上学习相关介绍和基本用法\n",
    "2. 用其他浏览器打开jupyter notebook 跳转链接为http://localhost:8888/ 需要token密码 可以直接在cmd运行中找到\n",
    "3. jupyter notebook写笔记时记得要转换语言\n",
    "### jupyter notebook的部分快捷键\n",
    "1. A会在活跃单位上插入一个新的单元，B在活跃单位下插入一个新单元\n",
    "2. 连续按两次D，可以删除一个单元\n",
    "3. 撤销被删除单元按Z"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0268efc2",
   "metadata": {},
   "source": [
    "## 项目一"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "88822550",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "时间是奇数,时间在odds的数据中\n"
     ]
    }
   ],
   "source": [
    "# 课本代码 （项目一：从奇数中选择对应的时间节点）\n",
    "from datetime import datetime\n",
    "\n",
    "odds = [ 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,48,51,53,55,57,59 ]\n",
    "# datetime.today (). minute 当前的时间的分钟\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds: \n",
    "    print (\"时间是奇数,时间在odds的数据中\")\n",
    "else: \n",
    "    print(\"Not an odd minute.\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d374c4fe",
   "metadata": {},
   "outputs": [],
   "source": [
    "#调用模块\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9ef16e4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 9, 27)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#datetime里面的date方法\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4b1bd4ab",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#datetime里面的date方法取年月日\n",
    "datetime.date.today().day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "76508800",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cc586434",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=9, tm_mday=27, tm_hour=21, tm_min=8, tm_sec=38, tm_wday=0, tm_yday=270, tm_isdst=0)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#本地时间\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "ebd948be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'21:09'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#格式化时间\n",
    "time.strftime(\"%H:%m\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "9e8f06e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-09-27'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#使用time的strftime方法找到年月日，然后拼接在一起就可以了\n",
    "time.strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "d3105e14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'PM'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%p\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "58b3851a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "8d2d4b23",
   "metadata": {},
   "source": [
    "### 变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b00502cb",
   "metadata": {},
   "source": [
    "### [变量解释](http://c.biancheng.net/view/2171.html)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c58116c",
   "metadata": {},
   "source": [
    "### 在编程语言中，将数据放入变量的过程叫做赋值（Assignment）。Python 使用等号=作为赋值运算符，具体格式为：\n",
    "### name = value\n",
    "\n",
    "### name 表示变量名；value 表示值，也就是要存储的数据。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e5d677bf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ZhiChao ZhiChao\n",
      " What is the value of name2 now?\n"
     ]
    }
   ],
   "source": [
    "name = \"ZhiChao\"\n",
    "name2 = name \n",
    "print(name,name2)\n",
    "name = \" Han-Teng \"\n",
    "print(\" What is the value of name2 now?\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b53430c7",
   "metadata": {},
   "source": [
    "### 字符串(str）\n",
    " ### [字符串的运用和解析](https://www.runoob.com/python/python-strings.html)\n",
    "### Python 三引号\n",
    "Python 中三引号可以将复杂的字符串进行赋值。\n",
    "\n",
    "Python 三引号允许一个字符串跨多行，字符串中可以包含换行符、制表符以及其他特殊字符。\n",
    "\n",
    "三引号的语法是一对连续的单引号或者双引号（通常都是成对的用）。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "77644810",
   "metadata": {},
   "source": [
    "### Python算术运算符\n",
    "#### +\t加 ,两个对象相加\ta + b 输出结果 30\n",
    "#### -\t减 , 得到负数或是一个数减去另一个数\ta - b 输出结果 -10\n",
    "#### *\t乘 ,两个数相乘或是返回一个被重复若干次的字符串\ta * b 输出结果 200\n",
    "#### /\t除, x除以y\tb / a 输出结果 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "2aefdd03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#和数学上的算法是一样的\n",
    "1+2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "4f5ec4b0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "doesn't\n",
      "doesn't\n"
     ]
    }
   ],
   "source": [
    "#当字符串中含有'时，为了能让计算机看懂，我们要用到\\，或者是”\n",
    "print('doesn\\'t')\n",
    "print( \"doesn't\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8cb4e25",
   "metadata": {},
   "source": [
    "### 字符串运算符"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f0d6c400",
   "metadata": {},
   "source": [
    "#### +\t字符串连接\t\n",
    "#### >>>a + b\n",
    "#### 'HelloPython'\n",
    "#### *\t重复输出字符串\t\n",
    "#### >>>a * 2\n",
    "#### 'HelloHello'\n",
    "#### []\t通过索引获取字符串中字符\t\n",
    "#### >>>a[1]\n",
    "#### 'e'\n",
    "#### [ : ]\t截取字符串中的一部分\t\n",
    "#### >>>a[1:4]\n",
    "#### 'ell'\n",
    "#### \\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4becd51",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
